﻿using System;
using System.Collections.Generic;
using System.Data;
using DAL;
using Entities;

namespace BLL
{
    public class BLL_MenuURL
    {
        private DAL_MenuURL dal_MenuURL = new DAL_MenuURL();

        public DataTable Get_MenuURL_All()
        {
            return dal_MenuURL.Get_MenuURL_All();
        }

        public DataTable Get_MenuURL(Int64 pID)
        {
            return dal_MenuURL.Get_MenuURL(pID);
        }

        public DataTable Get_MenuURL_Type(string pType)
        {
            return dal_MenuURL.Get_MenuURL_Type(pType);
        }

        public int Get_MenuURL_MaxColumn()
        {
            return dal_MenuURL.Get_MenuURL_MaxColumn();
        }

        public bool InsertUpdate_MenuURL(MenuURL pMenuURL)
        {
            return dal_MenuURL.InsertUpdate_MenuURL(pMenuURL);
        }

        public DataTable Get_MenuURL_Dynamic(string pCondition)
        {
            return dal_MenuURL.Get_MenuURL_Dynamic(pCondition);
        }

        public List<MenuURL> Lst_MenuURL(DataTable pdt)
        {
            List<MenuURL> lstReturn = new List<MenuURL>();
            if (pdt != null && pdt.Rows.Count > 0)
            {
                foreach (DataRow dr in pdt.Rows)
                {
                    MenuURL menuURL = new MenuURL();
                    menuURL.DESCRIPTION = Convert.ToString(dr["DESCRIPTION"]);
                    menuURL.ID = (dr["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ID"]));
                    menuURL.ID_PARENT = (dr["ID_PARENT"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ID_PARENT"]));
                    menuURL.NAME = Convert.ToString(dr["NAME"]);
                    menuURL.URL = Convert.ToString(dr["URL"]);
                    menuURL.TYPE = Convert.ToString(dr["TYPE"]);
                    menuURL.CODE = Convert.ToString(dr["CODE"]);
                    menuURL.IMAGE_DIRECTORY = Convert.ToString(dr["IMAGE_DIRECTORY"]);
                    menuURL.SEQUENCE = (dr["SEQUENCE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["SEQUENCE"]));
                    lstReturn.Add(menuURL);
                }
            }
            return lstReturn;
        }

        public bool DeleteMenuURL(Int64 pID)
        {
            return dal_MenuURL.DeleteMenuURL(pID);
        }
    }
}
